﻿#include "modbustcp.h"
#include "widgettcpcfg.h"

ModbusTcp::ModbusTcp(QObject *parent) : BaseModbus(parent)
{

}

void ModbusTcp::setConfig(QJsonObject obj)
{
    BaseModbus::setConfig(obj);
    QString address=_obj["address"].toString();
    const QUrl url = QUrl::fromUserInput(address);
    m_ctx=modbus_new_tcp(url.host().toLatin1().data(),url.port());
}

QWidget *ModbusTcp::getConfigWidget()
{
    WidgetTcpCfg *cfg=new WidgetTcpCfg();
    cfg->setComm(this);
    return cfg;
}
